home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.text;
-
- import com.sun.java.swing.JComponent;
- import java.awt.Component;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
-
- class DefaultEditorKit$PageUpAction extends TextAction {
- DefaultEditorKit$PageUpAction() {
- super("page-up");
- }
-
- public void actionPerformed(ActionEvent e) {
- JTextComponent target = ((TextAction)this).getTextComponent(e);
- if (target != null) {
- Rectangle visible = new Rectangle();
- ((JComponent)target).computeVisibleRect(visible);
- int scrollOffset = visible.y;
- visible.y -= visible.height;
- if (visible.y < 0) {
- visible.y = 0;
- }
-
- scrollOffset -= visible.y;
- ((JComponent)target).scrollRectToVisible(visible);
- int selectedIndex = target.getCaretPosition();
-
- try {
- if (selectedIndex != -1) {
- Rectangle r = target.modelToView(selectedIndex);
- r.y -= scrollOffset;
- selectedIndex = target.viewToModel(new Point(r.x, r.y));
- if (selectedIndex < 0) {
- selectedIndex = 0;
- }
-
- target.setCaretPosition(selectedIndex);
- }
- } catch (BadLocationException var7) {
- ((Component)target).getToolkit().beep();
- }
- }
-
- }
- }
-